<?php
namespace App\Admin\Tools;

use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid\Tools\AbstractTool;

class OrderExportTool extends AbstractTool
{
	protected function script()
	{
		return <<<EOT
$('#orders-export').change(function () {
	let url = $(this).find('option:selected').val();

	var params = new URLSearchParams(window.location.search);
    var vendor_id = params.get('vendor_id');
	
	
	if (url !== '0') {
		if(vendor_id){

			location.href = url+"?vendor_id="+vendor_id;
		}else{

			location.href = url;
		}
		
	}
});
EOT;

	}
	
	public function render()
	{
		Admin::script($this->script());
		
		$options = [];
		return view('admin.tools.orderexport', compact('options'));
	}
}